<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3-2-属性侦听器-组合式</title>
</head>

<body>


    <!--载入vue.js-->
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

    <div id="Application">
        <h3>您输入的文本不能超过10个</h3>
        <input v-model="searchText" />
    </div>



    <script>
        const app = Vue.createApp({
            setup() {
                const searchText = Vue.ref("");

                Vue.watch(searchText, (value, old) => {
                    if (old.length > 10) {
                        alert("文本太长了")
                    }
                }

                )

                return {
                    searchText
                }
            }
        })


        app.mount("#Application")
    </script>

    <style>

    </style>


</body>

</html>